<?php
require_once( 'classes/class.Spectre.php' );

$oTemplate = new Spectre();



$aExampleData = array(
	array( 'id' => '1', 'date' => '18-01-2010', 'title' => 'This is title 1' ),
	array( 'id' => '5', 'date' => '22-01-2010', 'title' => 'This is title 5' ),
	array( 'id' => '7', 'date' => '24-01-2010', 'title' => 'This is title 7' ),
);
$aExampleTitles = array(
	'ID' , 'DATE' , 'TITLE'
);

foreach( $aExampleTitles as $sTitle ) {
	$aRows['test2_title'][]['tags']['value'] = $sTitle;
}

foreach( $aExampleData as $iRow => $aRow ) {
	$aRows['test1_row'][]['tags'] = $aRow;
	foreach( $aRow as $sField ) {
		$aRows['test2_row'][$iRow]['rowset']['test2_column'][]['tags']['value'] = $sField;
	}
}

$iStart = microtime( true );

ob_start( 'ob_gzhandler' );

/**
 * This is the call to set a custom optimiser location which handles
 */
$oTemplate->optimiserFile( 'templates/load.php' );
/**
 * Absolute Site Path. When this is set it will not try to autolocate and will in fact take out
 * all "../"'s from the the src files and attempt to find them by prepending this to the
 * path. 
 */
$oTemplate->sitePath( dirname( __FILE__ ).'/' );



$oTemplate->setTemplate( 'template' , 'templates/template.html' );
$oTemplate->setRows( $aRows , 'template' );
// New Experimental CSS/JS Optimisation Techniques.
$sContent = $oTemplate->parseTemplate( 'template' , true );
//$sContent = $oTemplate->parseTemplate( 'template' , false );

//echo ((microtime( true ) - $iStart)*1000) . 'ms';

echo $sContent;